<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>菜鸟教程 React 实例</title>
<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/prop-types/15.6.1/prop-types.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>
<h1>pros 验证数据合法性</h1>
<p>propTypes 判断数据类型是否合法，声明类型为PropTypes.string 字符串类型，如果数据不会string类型会自动转换为string类型</p>
<div id="example"></div>
<script type="text/babel">
	 var title= "无间道";
	// var title = 123;
	class MyTitle extends React.Component{
		render(){
			return <h2>{this.props.title}</h2>
		}
	}
	
	MyTitle.propTypes = {
		title: PropTypes.number
	};
	
	ReactDOM.render(
		<MyTitle title = {title}/>,
		document.getElementById('example')
	);
</script>

</body>
</html>